<!DOCTYPE HTML>
<html  lang="zh" xmlns:th="http://www.thymeleaf.org">
<meta charset="utf-8">
<head th:include="include :: header"></head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-sysSmsTemplate-add">
			<div class="form-group">	
				<label class="col-sm-3 control-label">模版名称：</label>
				<div class="col-sm-8">
					<input id="name" name="name" class="form-control" type="text">
				</div>
			</div>
			<div class="form-group">	
				<label class="col-sm-3 control-label">模版编码：</label>
				<div class="col-sm-8">
					<input id="code" name="code" class="form-control" type="text">
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label">业务类型：</label>
				<div class="col-sm-8">
					<select id="businessType" name="businessType" class="form-control m-b" th:with="type=${@dict.getType('sms_business_type')}">
	                    <option th:each="dict : ${type}" th:text="${dict['dictLabel']}" th:value="${dict['dictValue']}"></option>
	                </select>
				</div>
			</div>
			<div class="form-group">	
				<label class="col-sm-3 control-label">模版ID：</label>
				<div class="col-sm-8">
					<input id="templateId" name="templateId" class="form-control" type="text">
				</div>
			</div>
			<div class="form-group">	
				<label class="col-sm-3 control-label">模版内容：</label>
				<div class="col-sm-8">
					<textarea id="templateContent" name="templateContent" class="form-control"></textarea>
					<span>有效期时间参数：{effctiveTime}</span>
				</div>
			</div>
			<div class="form-group">	
				<label class="col-sm-3 control-label">备注信息：</label>
				<div class="col-sm-8">
					<input id="remarks" name="remarks" class="form-control" type="text">
				</div>
			</div>
		</form>
	</div>
    <div th:include="include::footer"></div>
    <script type="text/javascript">
		var prefix = ctx + "message/sysSmsTemplate"
		$("#form-sysSmsTemplate-add").validate({
			rules:{
				templateId:{
        			required:true,
        			remote: {
                        url: prefix + "/checkTemplateIdUnique",
                        type: "post",
                        dataType: "json",
                        data: {
                        	"templateId" : function() {
                                return $.trim($("#templateId").val());
                            }
                        },
                        dataFilter: function(data, type) {
                            if (data == "0") return true;
                            else return false;
                        }
                    }
        		},
        		orderNum:{
        			required:true,
        			digits:true
        		},
        	},
        	messages: {
                "templateId": {
                    remote: "模板ID已经存在"
                }
            }
			focusCleanup: true
		});
		
		function submitHandler() {
	        if ($.validate.form()) {
	            $.operate.save(prefix + "/add", $('#form-sysSmsTemplate-add').serialize());
	        }
	    }
	</script>
</body>
</html>
